﻿package mortal.game.view.interfaceCallModule
{
    import Engine.RMI.*;
    import com.mui.controls.*;
    import flash.events.*;
    import mortal.component.window.*;
    import mortal.game.cache.*;
    import mortal.game.view.common.*;
    import mortal.mvc.interfaces.*;

    public class InterfaceCallModule extends SmallWindow
    {
        private var _tf:GTextArea;
        private var _tf2:GTextArea;
        private var _stopUpdate:GCheckBox;
        private var _updateRecord:GButton;

        public function InterfaceCallModule(param1:ILayer = null)
        {
            super(param1);
            titleHeight = 22;
            setSize(580, 400);
            return;
        }// end function

        override public function show(param1:int = 0, param2:int = 0) : void
        {
            super.show();
            this.onUpdateRecord();
            RMIDispatcher.getInstance().addEventListener(RMIEvent.SHOW_INTERFACE_TYPE, this.onShowInterfaceName);
            return;
        }// end function

        override public function hide() : void
        {
            super.hide();
            RMIDispatcher.getInstance().removeEventListener(RMIEvent.SHOW_INTERFACE_TYPE, this.onShowInterfaceName);
            this._tf.htmlText = "";
            return;
        }// end function

        private function onShowInterfaceName(event:RMIEvent) : void
        {
            if (this._stopUpdate.selected)
            {
                return;
            }
            var _loc_2:* = event.interfaceName.replace("[object", "").replace("]", "");
            this._tf.htmlText = this._tf.htmlText + (_loc_2 + "<br>");
            this._tf.verticalScrollPosition = this._tf.maxVerticalScrollPosition;
            return;
        }// end function

        private function onUpdateRecord(event:MouseEvent = null) : void
        {
            this._tf2.htmlText = Cache.instance.interfaceCall.record;
            this._tf2.verticalScrollPosition = this._tf2.maxVerticalScrollPosition;
            return;
        }// end function

        override protected function createDisposedChildrenImpl() : void
        {
            super.createDisposedChildrenImpl();
            pushUIToDisposeVec(UIFactory.gTextField("即时打印：", 16, 29, 100, 20, this));
            pushUIToDisposeVec(UIFactory.gTextField("记录打印：", 300, 29, 100, 20, this));
            this._tf = UIFactory.textArea("", 20, 55, 265, 340, this);
            pushUIToDisposeVec(this._tf);
            this._tf2 = UIFactory.textArea("", 300, 55, 265, 340, this);
            pushUIToDisposeVec(this._tf2);
            this._stopUpdate = UIFactory.checkBox("停止更新", 100, 29, 150, 28, this);
            pushUIToDisposeVec(this._stopUpdate);
            this._updateRecord = UIFactory.gButton("刷新打印", 480, 30, 62, 24, this);
            this._updateRecord.configEventListener(MouseEvent.CLICK, this.onUpdateRecord);
            pushUIToDisposeVec(this._updateRecord);
            return;
        }// end function

    }
}
